﻿using System;
using System.Windows.Controls;

using Microsoft.Phone.Controls;

namespace SipCompensation
{
    public static class SipHelper
    {
        private static PhoneApplicationFrame _frame;

        /// <summary>
        /// Should be called once.
        /// </summary>
        public static void Init(PhoneApplicationFrame frame)
        {
            _frame = frame;
        }

        /// <summary>
        /// Fixes scrolling issues when SIP (Software Input Panel) is open.
        /// Dispose should be called to avoid memory leak.
        /// </summary>
        public static IDisposable EnableCompensationFor(ScrollViewer scrollViewer)
        {
            if (_frame == null)
                throw new InvalidOperationException("SipHelper wasn't initialized");

            return new KeyboardPageCompensation(_frame, scrollViewer);
        }
    }
}
